<include file="Public:header" />
<div class="container main"> <include file="Public:left" />
    <div class="w790">
        <script>
            function uploaded(path){
                $("#img_url").attr("src",'__PUBLIC__'+path);
                $("input[name='img_url']").val(path);
            }
            function del_img(){
                if(confirm('您确定要删除图片吗?')){
                    var file=$("input[name='img_url']").val();
                    $.post("{:U('delImgBypath')}",{'path':file},function(data){
                        $("input[name='img_url']").val('');
                        $("#img_url").attr('src','');
                    });
                }else{
                    return false;
                }
            }
            //切换栏目方式
            function parseCateType(e){
                if($(e).val()==1){
                    $('#pagesize').show();
                }else{
                    $('#pagesize').hide();
                }
            }
            function after(e){
                $(e).parent().parent().parent().parent().parent('li').after($(e).parent().parent().parent().parent().parent('li').prev());
            }
            function append(e){
                $(e).parent().parent().parent().parent().parent('li').next().after($(e).parent().parent().parent().parent().parent('li'));
            }
            function delnews(e){
                $(e).parent().parent().parent().parent().parent().remove();
            }
            function addnews(){
                var html = $('#copyHTML').html();
                $(html).appendTo('#replyList ul');
            }


            function getExtends(e){
                var v = $('#extendsList'+$(e).val()).val();
                $('#extends').val(v);
            }
        </script>
        <style>
            #replyList ul li{margin-top:5px; background:#eee; padding:8px; width:700px;}
            .delnews{display:block; width:30px; font-size:20px; height:30px; border-radius:15px; background:#f00; color:#fff; line-height:30px; text-align:center;}
        </style>

        <div class="h"><a href="{:U('index')}" class="btn btn-info"><i class="glyphicon glyphicon-circle-arrow-left"></i> 返回供货商列表</a>

        </div>
        <form class="checkoutform1 form-horizontal" action="{:U('update')}" method="post">
            <div class="table_ container">

                <input class="form-control" value="{$info.id}" name="id" type="hidden">



                <div class="form-group">
                    <label class="col-sm-2 control-label">名称</label>
                    <div class="col-sm-10">
                        <input class="form-control" datatype="*" value="{$info.susername}" name="susername" type="text" placeholder="供货商名称">
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-2 control-label">电话</label>
                    <div class="col-sm-10">
                        <input class="form-control" name="sphone" value="{$info.sphone}" type="text" placeholder="电话">
                    </div>
                </div>



                <div class="form-group">
                    <label class="col-sm-2 control-label">地区</label>
                    <div class="col-sm-10">
                        <span id="areabox"></span>
                    </div>

                </div>





                <div class="form-group">
                    <label class="col-sm-2 control-label">地址</label>
                    <div class="col-sm-10">
                        <input class="form-control" value="{$info.saddress}" name="saddress" type="text" placeholder="地址">
                    </div>
                </div><div class="form-group">
                <label class="col-sm-2 control-label">店名</label>
                <div class="col-sm-10">
                    <input class="form-control" value="{$info.shopname}" name="shopname" type="text" placeholder="店名">
                </div>
            </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">百度地图坐标</label>
                    <div class="col-sm-6">
                        <input class="form-control" value="{$info.baidumapX},{$info.baidumapY}" name="baidupoint" id="txtPoint" type="text" placeholder="百度地图坐标">
                    </div><div class="col-sm-4">
                    <a href="##" class="btn btn-success">打开百度地图</a>
                </div>
                </div>





                <div class="form-group">
                    <label class="col-sm-2 control-label">　</label><div class="col-sm-10">
                    <style type="text/css">

                        #l-map{height:500px;}
                        #r-result{overflow-y:scroll; height:500px;}
                    </style>
                    <div class="row">

                        <div class="col-sm-6">
                            <input class="form-control" id="txtCity" type="text" placeholder="输入城市名称">
                        </div><div class="col-sm-4">
                        <a href="##" onClick="getPoint();" class="btn btn-success">搜索</a>
                    </div></div>

                    <div class="row" style="margin-top:12px; padding:15px;"><div class="col-sm-8" id="l-map"></div>
                        <div id="r-result" class="col-sm-4"></div></div></div>





                    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=QMDvD2Anle2gLOINIBUZ1Lhh"></script>
                    <script type="text/javascript">
                        // 百度地图API功能

                        var map = new BMap.Map("l-map");            // 创建Map实例
                        map.centerAndZoom(new BMap.Point(113.342754,23.653305), 8);
                        map.enableScrollWheelZoom();



                        var point = new BMap.Point({$info.baidupoint});
                        var marker = new BMap.Marker(point);  // 创建标注
                        map.addOverlay(marker);

                        var local = new BMap.LocalSearch("东莞", {
                            renderOptions: {
                                map: map,
                                panel : "r-result",
                                autoViewport: true,
                                selectFirstResult: false
                            },
                            onResultsHtmlSet:function(container){
                                $(container).find('li').each(function(index, element) {
                                    $(this).click(function(e) {

                                        document.getElementById("txtPoint").value=local.getResults().getPoi(index).point.lng + "," + local.getResults().getPoi(index).point.lat;
                                    });

                                });
                                //alert(local.getResults().getNumPois());

                            }
                        });
                        map.addEventListener("click",function(e){

                            document.getElementById("txtPoint").value=e.point.lng + "," + e.point.lat;
                        });
                        function getPoint(){

                            var city = document.getElementById("txtCity").value;
                            local.search(city);                 // 初始化地图,设置城市和地图级别。
                            //启用滚轮放大缩小

                        }

                    </script>



                </div>













                <div class="form-group">
                    <label class="col-sm-2 control-label">联系人</label>
                    <div class="col-sm-10">
                        <input class="form-control" value="{$info.contacts}" name="contacts" type="text" placeholder="联系人">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label">备注</label>
                    <div class="col-sm-10">
                        <input class="form-control" value="{$info.remark}" name="remark" type="text" placeholder="备注">
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-2 control-label">封面图</label>
                    <div class="col-sm-10">
                        <input name="img_url" type="hidden" value="{$info.img_url}" /><img onclick="showImgBox(this);" src="<notempty name="info['img_url']">{:getThumbPath($info['img_url'])}<else/>__PUBLIC__/Admin/images/defaultimg.png</notempty>" id="img_url" height="40" />
                    </div>
                </div>



                <div class="form-group">
                    <label class="col-sm-2 control-label">详细介绍</label>
                    <div class="col-sm-10">
                        <html:editor id="editor" name="introduction" type="UEDIT" style="height:400px; width:100%;">{$info.introduction}</html:editor>
                    </div>
                </div>

            </div><div class="pages"><button type="submit" class="btn btn-success">保存</button></div>
        </form>
    </div>
    <div class="clear"></div>
</div>
<script>

    $(document).ready(function(e) {

        <empty name="info['area']">
            $.ajax({
                url:"{:U('getRegion')}",
                data:"",
                type:"POST",
                dataType:"html",
                success: function(data){
                    $('#areabox').html(data);
                }
            });

        <else/>


        $.ajax({
            url:"{:U('setRegion')}",
            data:"area={$info.area}",
            type:"POST",
            dataType:"html",
            success: function(data){
                $('#areabox').html(data);
            }
        });

        </empty>
    });
    function removnextAll(e){
        if($(e).next().length>0){
            removnextAll($(e).next());
            $(e).next().remove();
        }
    }
    function sendRegion(e){
        if(e.value>0){
            $.ajax({
                url:"{:U('getRegion')}",
                data:"fid="+e.value,
                type:"POST",
                dataType:"html",
                success: function(data){
                    removnextAll(e);
                    $(e).parent().append(data);
                }
            });
        }else{
            removnextAll(e);
        }
        return false;
    }

</script>
</body></html>